(function($) {
    $.fn.jCarouselLite = function(o) {
        o = $.extend({
            btnPrev: null, btnNext: null, btnGo: null, mouseWheel: false, auto: null, speed: 200, easing: null, vertical: false, circular: true, visible: 3, start: 0, scroll: 1, beforeStart: null, play: true,
            afterEnd: null
        }, o || {});
        return this.each(function() {
            var b = false, animCss = o.vertical ? "top" : "left", sizeCss = o.vertical ? "height" : "width";
            var c = $(this), ul = $("ul", c), tLi = $("li", ul), tl = tLi.size(), v = o.visible;
            ul.bind("mouseover", function() {
                if (o.play) {
                    o.play = false;
                }
            })
            ul.bind("mouseout", function() {
                if (!o.play) {
                    o.play = true;
                }
            })
            if (o.circular) {
                ul.prepend(tLi.slice(tl - v - 1 + 1).clone()).append(tLi.slice(0, v).clone());
                o.start += v
            }
            var f = $("li", ul), itemLength = f.size(), curr = o.start; c.css("visibility", "visible");
            f.css({ overflow: "hidden", float: o.vertical ? "none" : "left" });
            ul.css({ margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1" });
            c.css({ overflow: "hidden", position: "relative", "z-index": "2", left: "0px" });
            var g = o.vertical ? height(f) : width(f);
            var h = g * itemLength;
            var j = g * v; f.css({ width: f.width(), height: f.height() });
            ul.css(sizeCss, h + "px").css(animCss, -(curr * g));
            c.css(sizeCss, j + "px");
            if (o.btnPrev) $(o.btnPrev).click(function() {
                return go(curr - o.scroll)
            });
            if (o.btnNext) $(o.btnNext).click(function() {
                return go(curr + o.scroll)
            });
            if (o.btnGo) $.each(o.btnGo, function(i, a) {
                $(a).click(function() { return go(o.circular ? o.visible + i : i) })
            });
            if (o.mouseWheel && c.mousewheel) c.mousewheel(function(e, d) {
                return d > 0 ? go(curr - o.scroll) : go(curr + o.scroll)
            });
            if (o.auto) {
                setInterval(AutoPlay, o.auto + o.speed);
            }
            function vis() {
                return f.slice(curr).slice(0, v)
            };
            function AutoPlay() { if (o.play) { go(curr + o.scroll); } };
            function go(a) {
                if (!b) {
                    if (o.beforeStart) o.beforeStart.call(this, vis());
                    if (o.circular) {
                        if (a <= o.start - v - 1) {
                            ul.css(animCss, -((itemLength - (v * 2)) * g) + "px");
                            curr = a == o.start - v - 1 ? itemLength - (v * 2) - 1 : itemLength - (v * 2) - o.scroll
                        }
                        else if (a >= itemLength - v + 1) {
                            ul.css(animCss, -((v) * g) + "px");
                            curr = a == itemLength - v + 1 ? v + 1 : v + o.scroll
                        }
                        else
                            curr = a
                    }
                    else {
                        if (a < 0 || a > itemLength - v)
                            return;
                        else curr = a
                    }
                    b = true;
                    ul.animate(animCss == "left" ? { left: -(curr * g)} : { top: -(curr * g) }, o.speed, o.easing, function() {
                        if (o.afterEnd) o.afterEnd.call(this, vis()); b = false
                    });
                    if (!o.circular) {
                        $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
                        $((curr - o.scroll < 0 && o.btnPrev) || (curr + o.scroll > itemLength - v && o.btnNext) || []).addClass("disabled")
                    }
                } return false
            }
        })
    };
    function css(a, b) { return parseInt($.css(a[0], b)) || 0 };
    function width(a) { return a[0].offsetWidth + css(a, 'marginLeft') + css(a, 'marginRight') };
    function height(a) { return a[0].offsetHeight + css(a, 'marginTop') + css(a, 'marginBottom') }

})(jQuery);

$(function(){
$("html").mousemove(function(e){
	$("#pagey").css({"top":(e.pageY+20)+"px","left":(e.pageX+10)+"px"}).html((e.pageY)+"<br/>"+(e.pageX));
	})
	
	var $this = $(".scrollNews");
	var $this1 = $(".scrollNews1");
	var scrollTimer;
	var scrollTimer1;
	$this.hover(function(){
		clearInterval(scrollTimer);
		},function(){
			scrollTimer = setInterval(function(){
				scrollNews($this);
				},2000);
			}).trigger("mouseleave");
			
	$this1.hover(function(){
		clearInterval(scrollTimer1);
		},function(){
			scrollTimer1 = setInterval(function(){
				abc($this1);
				},2000);
			}).trigger("mouseleave");		
			
	var div1=$(".scrollNews12");
	var scrollt;
	div1.hover(function(){
		clearInterval(scrollt);
		},function(){
			scrollt = setInterval(function(){
				ccdc(div1);
				},2000);
			}).trigger("mouseleave");		
/*	var x =10; //设置默认X值
	var y= 20;//设置默认Y值
	$(".scrollNews12 a").mouseover(function(e){//当鼠标移到
		this.mytitle = this.title;
		this.title = "";
		var tooltip = "<div id='tooltip'>"+this.mytitle+"</div>";
		$("body").append(tooltip);
		$("#tooltip").css({"top":(e.pageY+y)+"px","left":(e.pageX+x)+"px"}).show("fast");
		}.mouseout(function(){
			this.title = this.mytitle;
			$("#tooltip").remove();
			}).mousemove(function(e){
				$("#tooltip").css({"top":(e.pageY+y)+"px","left":(e.pageX+x)+"px"});
				}))*/
	});
function scrollNews(a){
	var $self = a.find("ul:first");
	var lineheight = $self.find("li:first").width();
	$self.animate({"marginLeft":-lineheight+"px"},600,function(){
		$self.css({marginLeft:0}).find("li:first").appendTo($self);
		})	
	}

function ccdc(obj){
	var ab =obj.find("ul:first");
	var ac=ab.find("li:first").height();
	ab.animate({"marginTop":-ac+"px"},800,function(){
		ab.css({marginTop:0}).find("li:first").appendTo(ab);
		})
	}
	
function abc(cc){
	var ccd = cc.find("ul:first");
	var widthc = ccd.find("li:first").height();	
	ccd.animate({"marginTop":-widthc+"px"},800,function(){
		ccd.css({marginTop:0}).find("li:first").appendTo(ccd);
		})	}